@push('title')
    <title>同程比价</title>
@endpush
@push('style2')

@endpush
@extends('layout.layer')
@section('content')

<form class="layui-form"> <!-- 提示：如果你不想用form，你可以换成div等任何一个普通元素 -->
        <div class="layui-form-item">
            <div class="layui-inline">
                <label class="layui-form-label">报销类型</label>
                <div class="layui-input-block">
                    <select name="reimbursementType" lay-filter="aihao">
                        <option value="2">发票+行程单</option>
                        <option value="1">行程单</option>
                    </select>
                </div>
            </div>
            <div class="layui-inline">
                <label class="layui-form-label">航司</label>
                <div class="layui-input-block">
                    <input type="text" name="airlineCode" value="" placeholder="请选择" class="layui-input" style="width:160px;">
                </div>
            </div>
            <div class="layui-inline" style="width: 420px;">
                <label class="layui-form-label">起抵机场</label>
                <div class="layui-input-block" style="display: flex; justify-content: flex-start; align-items: center;">
                    <input type="text" name="startPort" value="" placeholder="请输入" autocomplete="off" class="layui-input"
                        style="width:160px;">
                    <span style="padding: 0 10px;">-</span>
                    <input type="text" name="endPort" value="" placeholder="请输入" autocomplete="off" class="layui-input"
                        style="width:160px;">
                </div>
            </div>

            <div class="layui-inline" style="width: 420px;">
                <label class="layui-form-label">航班日期</label>
                <div class="layui-input-block" style="display: flex; justify-content: flex-start; align-items: center;">
                    <input type="text" name="startDate" value="" placeholder="政策旅行日期" class="layui-input" id="laydate1" style="width:160px;">
                    <span style="padding: 0 10px;">-</span>
                    <input type="text" name="endDate" placeholder="请选择" class="layui-input" id="laydate2" style="width:160px;">
                </div>
            </div>
            <div class="layui-inline">
                <label class="layui-form-label">航班号</label>
                <div class="layui-input-block">
                    <input type="text" name="flightNo" placeholder="请输入航班号,多个键入" autocomplete="off" class="layui-input">
                </div>
            </div>
            <div class="layui-inline">
                <label class="layui-form-label">状态</label>
                <div class="layui-input-block">
                    <select name="interest" lay-filter="aihao">
                        <option value="0">请选择</option>
                        <option value="1">未投放</option>
                        <option value="2">未胜出</option>
                        <option value="3">已胜出</option>
                        <option value="4">已呈现</option>
                    </select>
                </div>
            </div>
            <div class="layui-inline">
                <label class="layui-form-label">是否比价投放</label>
                <div class="layui-input-block">
                    <select name="interest" lay-filter="aihao">
                        <option value="0">是</option>
                        <option value="1">否</option>
                    </select>
                </div>
            </div>
            <div class="layui-inline">
                <label class="layui-form-label">是否共享</label>
                <div class="layui-input-block">
                    <select name="shareType" lay-filter="aihao">
                        <option value="0">请选择</option>
                        <option value="1">共享</option>
                        <option value="2">非共享</option>
                    </select>
                </div>
            </div>
            <div class="layui-inline">
                <div class="layui-input-block">
                    <button class="layui-btn" lay-submit lay-filter="formDemo">查询</button>
                    <button type="reset" class="layui-btn layui-btn-primary">重置</button>
                    <button class="layui-btn">导出</button>
                </div>
            </div>
        </div>


    </form>
    <form class="layui-form"
        style="background-color: #ffffff;border-left:1px solid #eee;border-top:1px solid #eee;border-right:1px solid #eee;margin-top:10;">
        <div class="layui-form-item" style="margin-bottom:0;padding: 10px 0;">
            <div style="display: flex;justify-content: flex-start;align-items:center;">
                <div style="margin-left:20px">
                    <button class="layui-btn layui-btn-sm" lay-submit lay-filter="formDemo">批量投放</button>
                    <button class="layui-btn layui-btn-sm layui-btn-danger" lay-submit
                        lay-filter="formDemo">取消投放</button>
                </div>
            </div>
        </div>
    </form>
    <table id="list" lay-filter="list"></table>

@endsection
@push('script')
    <script>
        layui.use(['table', 'form', 'laydate'], function () {
        var table = layui.table;
        var laydate = layui.laydate;
        var form = layui.form;

        //执行一个laydate实例
        laydate.render({
            elem: '#laydate1' //指定元素
        });
        laydate.render({
            elem: '#laydate2' //指定元素
        });

        //监听提交
        form.on('submit(formDemo)', function (data) {

            table.reload('list',{
                page: {
                    curr: 1 //重新从第 1 页开始
                }
                ,where:data.field
            });

            return false;
        });

        //第一个实例
        table.render({
            elem: '#list'
             , url: '/compare/ajaxTc' //数据接口
            ,page: false
            ,limit : 10000
            ,height: 600
            ,parseData: function (res) { //将原始数据解析成 table 组件所规定的数据
                if(res.errcode != null && res.errcode != 0){ // 判断数据是否为空

                    layer.msg(res.errmsg, {
                        offset: '15px'
                        ,icon: 5
                        ,time: 2000
                    });
                }

                return {
                    "code": res.errcode, //解析接口状态
                    "msg": res.errmsg, //解析提示文本
                    "data":res.data,
                    "count": res.data.length, //解析数据长度
                };
            }
            ,scrollY: true // 开启垂直滚动
            ,scrollX: true // 开启水平滚动
            , cols: [[ //表头
                { type: 'checkbox', fixed: 'left' }
                , {type: 'numbers',title: '序号', width: 80,  fixed: 'left'}
                , { field: 'winState', title: '状态' ,width: 100,templet:function (row) {
                        if(row.winState == 0) {
                            return '<span style="padding: 5px 10px;border-radius: 3px;color: #909399;border-color: #e9e9eb;background-color: #f4f4f5">未胜出</span>';
                        } else  if(row.winState == 1) {
                            return '<span style="padding: 5px 10px;border-radius: 3px;color: #67c231;border-color: #e1f3d8;background-color: #f0f9eb;">已呈现</span>';
                        } else  if(row.winState == 2) {
                            return '<span style="color:#409EFF;background-color: #ecf5ff;border-color:#d9ecff;padding: 5px 10px;border-radius: 3px">未呈现</span>';
                        }
                        return '<span style="color: #409EFF;background-color: #ecf5ff;border-color:#d9ecff;padding: 5px 10px;border-radius: 3px">未投放</span>';
                    }}
                , { field: 'productPinName', title: '产品号位',width: 100 }
                , { field: 'flyDate', title: '起飞时间' ,width: 120,templet:function (row) {
                        return row.flyDate.replaceAll('-','/');
                    }  }
                , { field: 'airlineCode', title: '航空公司' ,width: 100}
                , { field: 'flightNo', title: '航班号',width: 100 }
                , { field: 'carrierFlightNo', title: '承运航班号',width: 100 }
                , { field: 'startPort', title: '起飞地',width: 80  }
                , { field: 'endPort', title: '抵达地',width: 80 }
                , { field: 'cabinCode', title: '舱位', }
                , { field: 'isSupplierResBidRoute', title: '是否奖励航线' , width: 120,templet: function (row) {
                        if(row.isSupplierResBidRoute == 0) {
                            return '否';
                        }
                        return '是';
                    }}
                , { field: 'fareRuleDetail', title: '运价限制', width: 180, templet:function (row) {

                        var limitStr = '';
                        if (row.fareRuleDetail != null) {

                            limitStr += 'FRSC11';
                            if(row.fareRuleDetail.ageRange.length > 0) {


                            }

                            if(row.fareRuleDetail.idType.length > 0) {

                                limitStr += '<br>，&nbsp;&nbsp;证件类型：'
                                for (index = 0; index < row.fareRuleDetail.idType.length; index++) {

                                    limitStr += row.fareRuleDetail.idType[index].name;

                                }

                            }

                        }

                        return limitStr;

                    } }
                , { field: 'fareType', title: '运价类型', width: 120 ,templet:function (row) {
                        switch (row.fareType){
                            case '1': return '公布运价';
                            case '2': return '私有运价';
                            case '5': return '官网B2C运价';
                            case '9': return '官网B2B运价';
                        }
                        return row.fareType;
                    }}
                , { field: 'cabinMinFdPrice', title: '外放正价', width: 120 }
                , { field: 'minPrice', title: '最低结算价',width: 120  }
                , { field: 'selfPrice', title: '自家最低结算价',width: 140 }
                , { field: 'wealth5', title: '自家与平台差价', width: 140,emplet:function (row) {
                        if(row.selfPrice - row.minPrice > 0) {
                            return row.selfPrice - row.minPrice;
                        }
                        return '';
                    } }
                , { field: 'policyId', title: '自家政策id',width: 120 }
                , { field: '', title: '是否比价投放',  width: 120}
            ]]
        });

    });
    </script>
<style>
    .layui-inline {
        width: 350px;
    }
</style>
@endpush
